<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>创作界面</title>
    <link rel="stylesheet" href="${request.contextPath}/layuiadmin/layui/css/layui.css" media="all">
</head>
<style>
    .layui-layer-page .layui-layer-content {
        overflow: visible !important;
    }
</style>
<body style="background-color: #F2F2F2;" >
<div style="padding: 20px; ">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <form class="layui-form" method="post" style="margin-top: 10px" lay-filter="dataForm">
                        <input type="text" name="id"  autocomplete="off" class="layui-input" value="${(item.id)!}" style="display: none">

                        <div class="layui-form-item">
                            <label class="layui-form-label">姓名</label>
                            <div class="layui-input-block">
                                <input type="text" name="name" placeholder="" autocomplete="off" class="layui-input" value="${(item.name)!}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户名</label>
                            <div class="layui-input-block">
                                <input type="text" name="loginname" placeholder="" autocomplete="off" class="layui-input" value="${(item.loginname)!}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">性别</label>
                            <div class="layui-input-block">
                                <select id="sex" name="sex" lay-verify="required" lay-filter="sex">
                                    <option value="">请选择</option>
                                    <option value="男">男</option>
                                    <option value="女">女</option>
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">密码</label>
                            <div class="layui-input-block">
                                <input type="text" name="pwd" placeholder="" autocomplete="off" class="layui-input" value="${(item.pwd)!}">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">地址</label>
                            <div class="layui-input-block">
                                <input type="text" name="address" placeholder="" autocomplete="off" class="layui-input" value="${(item.address)!}">
                            </div>
                        </div>

                        <button id="add" class="layui-btn" lay-filter="submit" lay-submit style="display: none">提交</button>
                    </form>

                </div>
            </div>
        </div>
    </div>
</div>
<script src="${request.contextPath}/layuiadmin/layui/layui.js"></script>

<script>
    layui.config({
        base: '${request.contextPath}/layuiadmin/modules/' //静态资源所在路径
    }).extend({
        xmSelect: 'xm-select'
    }).use(['form','jquery','laydate','xmSelect'], function(){
       var form=layui.form;
       var $=layui.$;
        var laydate = layui.laydate;
        var xmSelect = layui.xmSelect;

        //回显性别
        form.val('dataForm', {
            "sex": "${(item.sex)!}" // "name": "value"
        });

        form.render();

        form.on('submit(submit)', function(data){
            console.log(data.field);
            $.ajax({
                type:"post",
                url: "${request.contextPath}/user/saveItem",
                contentType:'application/json; charset=UTF-8',
                data: JSON.stringify(data.field),
                // data: {customer:data.field},
                // data:data.field,
                success: function(res) {
                    console.log("=====success=====")
                    console.log(res)
                    if(res.code===200){
                        layer.alert(res.msg,{icon:1},function () {
                            //调用父页面的关闭方法。
                            parent.closeAddLayer();
                            parent.reloadCustomerList();
                        })
                    }
                },
                error: function(res) {
                    layer.alert(res.msg,{icon:2})
                }
            })
            return false;
        });
        window.closeLayer=function(index){
            layer.close(index)
        }


    });
</script>

</body>
</html>